package com.test.daily.leetcode.y2021.m10.day1030;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2021/10/30 下午 03:47
 * @version: 1.0
 */
public class SingleNumber {
    public int[] singleNumber(int[] nums) {
        int exor = 0;
        for(int num: nums){
            exor ^= num;
        }
        int rightestOne = exor & (~exor + 1);
        int ans = 0;
        for(int num: nums){
            if((num & rightestOne) == 0){
                ans ^= num;
            }
        }
        return new int[]{ans,ans^exor};
    }
}
